package com.macrounion.atv.controller.api;

import com.google.common.collect.Lists;
import com.macrounion.base.service.dto.StringRespDto;
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.macrounion.atv.processor.SendtoProcessor;
import com.macrounion.atv.service.entity.Sendto;
import com.macrounion.atv.service.entity.User;
import com.macrounion.atv.service.service.SendtoService;
import com.macrounion.base.controller.api.BaseApiController;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

@RestController
@RequestMapping("/api/sendto")
public class SendtoApiController extends BaseApiController<Sendto, Sendto, SendtoProcessor, SendtoService, Sendto,User> {
//    private static final Log log = LogFactory.getLog(SendtoApiController.class);
//    @GetMapping("/restartService")
//    public StringRespDto restart(){
//        log.error("tempdir==="+System.getProperty("java.io.tmpdir") + System.currentTimeMillis()+".bat");
//        ClassPathResource classPathResource = new ClassPathResource("restart.bat");
//        try {
//            File somethingFile = File.createTempFile("template_bat_copy", ".bat");
//            FileUtils.copyInputStreamToFile(classPathResource.getInputStream(), somethingFile);
//            log.error("restart.bat=========="+somethingFile.getAbsolutePath());
//            try {
//                Process ps = Runtime.getRuntime().exec(somethingFile.getAbsolutePath());
//                InputStream in = ps.getInputStream();
//                int c;
//                while ((c = in.read()) != -1) {
//                    System.out.print(c);// 如果你不需要看输出，这行可以注销掉
//                }
//                in.close();
//                ps.waitFor();
//
//            } catch (IOException ioe) {
//                ioe.printStackTrace();
//            } catch (InterruptedException e) {
//                // TODO Auto-generated catch block
//                e.printStackTrace();
//            }
//        } catch (IOException e) {
//            log.error("error================="+e.getMessage()+"|||"+e.getStackTrace());
//            e.printStackTrace();
//        }
//
//        return new StringRespDto("ssss");
//    }
}